<!DOCTYPE html>
<body>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id=log></div>
<select onchange="handleChange();">
<option accesskey=1 selcted>o1
<option accesskey=2>o2
</select>

<script>
var changeEventCounter = 0;
var select1 = document.querySelector('select');

function handleChange() {
    ++changeEventCounter;
}

test(function() {
    changeEventCounter = 0;
    assert_equals(select1.selectedIndex, 0);
    eventSender.keyDown('1', 'accessKey');
    assert_equals(select1.selectedIndex, -1);
    assert_equals(changeEventCounter, 1);
}, 'Change event should be dsiaptched after deselecting the selected OPTION by accesskey.');

test(function() {
    changeEventCounter = 0;
    assert_equals(select1.selectedIndex, -1);
    eventSender.keyDown('1', 'accessKey');
    assert_equals(select1.selectedIndex, 0);
    assert_equals(changeEventCounter, 1);
}, 'Change event should be dsiaptched after selecting the selected OPTION by accesskey again.');
</script>
</body>
